<?php
include_once ("../Login/databaseconnection.php");
$q=$_GET["q"];
 $cs=explode(",",$q);
 $Subject=$cs[0];
 $Exam_Name=$cs[1];
$nam=$cs[2];
$tn=count($cs);
for($i=3;$i<$tn;$i++)
{
if(empty($adr))
{
$adr=$cs[$i];
}
else
{
$adr=$adr.",".$cs[$i];
}
}
$results= mysql_query("SELECT * FROM school Where Name='$nam' AND Address='$adr'");
if($row = mysql_fetch_array($results))
{
 $School_Id=$row['School_Id'];
}
$hint='';
$resulttable = mysql_query("SELECT DISTINCT(Year) FROM exam WHERE School_Id='$School_Id' AND Exam_Name='$Exam_Name' AND Subject='$Subject'");
if($resulttable)
{
$hint=$hint.'<select name="Year">';
$hint=$hint.'<option value="Select One">Select One</option>';
while($rowtable = mysql_fetch_array($resulttable))
{
$Year=$rowtable['Year'];

$hint=$hint.'<option value="'.$Year.'">'.$Year.'</option>';
}
  $hint=$hint.'</select>';
  }
  if($hint=='')
{ 
 $response=$response.'<select name="Year">';
   $response=$response.'<option value="Select One">Select One</option>';
	 $exa=mysql_query("SELECT DISTINCT(Year) FROM exam");
	  
  while($row=mysql_fetch_array($exa))
  {
   $Yea=$row['Year'];
	$response=$response.'<option value="'.$Yea.'">'.$Yea.'</option>';
  }
$response=$response.'</select>';
}
else
{
$response=$hint;
}
echo $response;
 ?>